﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Collections;
using System.Text.RegularExpressions;

namespace ExtractFiles
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }

        #region searchFiles methods
        private void searchFilesButton_Click(object sender, EventArgs e)
        {
            resultListBox.Items.Clear();
            string searchDirectoryPath = searchDirectoryTextBox.Text;
            string filesToSearchSourcePath = searchFilesSourceTextBox.Text;
            string destinationDirectoryPath = searchResultPathTextBox.Text;
            string[] filters = searchFilterTextBox.Text.Split(',');
            try
            {
                ArrayList results = SearchHelper.SearchFiles(searchDirectoryPath, filesToSearchSourcePath, filters);
                resultListBox.Items.AddRange(results.ToArray());
                try
                {
                    FileHelper.WriteToFile(destinationDirectoryPath, results);
                    MessageBox.Show("Number of files found: " + resultListBox.Items.Count.ToString());
                }
                catch (Exception ex)
                {
                    MessageBox.Show("An error has occurred while trying to write search result to file: " + ex.ToString());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error has occurred while trying to search files: " + ex.ToString());
            }
        }

        private void copyButton_Click(object sender, EventArgs e)
        {
            resultListBox.Items.Clear();
            string searchDirPath = searchDirectoryTextBox.Text;
            string copyDestDir = destinationDirectoryTextBox.Text;
            string searchResultFile = searchResultPathTextBox.Text;
            try
            {
                string[] files = FileHelper.ReadFromFile(searchResultFile);
                FileHelper.CopyToFile(files, searchDirPath, copyDestDir);
                resultListBox.Items.AddRange(files);
                MessageBox.Show("Number of files copied: " + resultListBox.Items.Count);
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error has occurred while trying to copy result files: " + ex.ToString());
            }
        }

        private void clearSearchResultButton_Click(object sender, EventArgs e)
        {
            this.searchDirectoryTextBox.Text = "";
            this.searchFilesSourceTextBox.Text = "";
            this.destinationDirectoryTextBox.Text = "";
            this.searchResultPathTextBox.Text = "";
            this.searchFilterTextBox.Text = "";
            this.resultListBox.Items.Clear();
        }

        private void browseDirButton_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog browseDirectoryDialog = new FolderBrowserDialog();
            browseDirectoryDialog.ShowDialog();
            string searchDirectory = browseDirectoryDialog.SelectedPath;
            this.searchDirectoryTextBox.Text = "";
            this.searchDirectoryTextBox.Text = searchDirectory;
        }

        private void browseFilesToSearchButton_Click(object sender, EventArgs e)
        {
            OpenFileDialog browseFilesToSearchDialog = new OpenFileDialog();
            browseFilesToSearchDialog.ShowDialog();
            string filesToSearchPath = browseFilesToSearchDialog.FileName;
            this.searchFilesSourceTextBox.Text = "";
            this.searchFilesSourceTextBox.Text = filesToSearchPath;
        }

        private void browseSearchResultPathButton_Click(object sender, EventArgs e)
        {
            OpenFileDialog browseSearchResultPathDialog = new OpenFileDialog();
            browseSearchResultPathDialog.ShowDialog();
            string searchResultPath = browseSearchResultPathDialog.FileName;
            this.searchResultPathTextBox.Text = "";
            this.searchResultPathTextBox.Text = searchResultPath;
        }

        private void browseCopyDestButton_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog browseCopyDestDialog = new FolderBrowserDialog();
            browseCopyDestDialog.ShowDialog();
            string copyDestPath = browseCopyDestDialog.SelectedPath;
            this.destinationDirectoryTextBox.Text = "";
            this.destinationDirectoryTextBox.Text = copyDestPath;
        }

        private void searchFilesTextBox_TextChanged(object sender, EventArgs e)
        {
            if (checkTextBoxNotEmpty("searchFilesTab"))
            {
                this.searchFilesButton.Enabled = true;
                this.copyButton.Enabled = true;
            }
            else
            {
                this.searchFilesButton.Enabled = false;
                this.copyButton.Enabled = false;
            }
        }

        private void resultListBox_DoubleClick(object sender, EventArgs e)
        {
            string filePath = "";
            try
            {
                filePath = resultListBox.SelectedItem.ToString();
                System.Diagnostics.Process.Start("notepad.exe", filePath);
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error has occurred while trying to open file " + filePath + ": " + ex.ToString());
            }
        }
        #endregion

        #region mergeFile methods
        private void mergeButton_Click(object sender, EventArgs e)
        {
            mergedFilesListBox.Items.Clear();
            string dirToMerge = dirToMergeTextBox.Text;
            string mergedFileDest = mergedFileDestTextBox.Text;
            string[] filters = mergedFilterTextBox.Text.Split(',');
            try
            {
                string lineStyle = checkLineStyle();
                bool isBackupTrue = checkBackupOption();
                string[] files = FileHelper.MergeToFile(dirToMerge, mergedFileDest, filters, lineStyle, isBackupTrue);
                mergedFilesListBox.Items.AddRange(files);
                DialogResult yesno = MessageBox.Show(mergedFilesListBox.Items.Count + " files merged. Do you want to open the merged file?", "Merged complete", MessageBoxButtons.YesNo);
                if (yesno == DialogResult.Yes)
                {
                    System.Diagnostics.Process.Start("notepad.exe", mergedFileDest);
                }
                else
                {
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error has occurred while trying to merge files: " + ex.ToString());
            }
        }

        private string checkLineStyle()
        {
            if (emptyLineStyleRadioButton.Checked)
            {
                return "emptyLine";
            }
            else
            {
                return "fileName";
            }
        }

        private bool checkBackupOption()
        {
            if (backupYesRadioButton.Checked)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        private void clearMergedFilesButton_Click(object sender, EventArgs e)
        {
            this.mergedFileDestTextBox.Text = "";
            this.dirToMergeTextBox.Text = "";
            this.emptyLineStyleRadioButton.Checked = false;
            this.fileNameStyleRadioButton.Checked = false;
            this.backupYesRadioButton.Checked = false;
            this.backupNoRadioButton.Checked = false;
            this.mergedFilesListBox.Items.Clear();
        }

        private void browseDirToMergeButton_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog browseDirToMergeDialog = new FolderBrowserDialog();
            browseDirToMergeDialog.ShowDialog();
            string dirToMerge = browseDirToMergeDialog.SelectedPath;
            this.dirToMergeTextBox.Text = "";
            this.dirToMergeTextBox.Text = dirToMerge;
        }

        private void browseMergedFileDestButton_Click(object sender, EventArgs e)
        {
            OpenFileDialog browseMergedFileDestDialog = new OpenFileDialog();
            browseMergedFileDestDialog.ShowDialog();
            string mergedFileDest = browseMergedFileDestDialog.FileName;
            this.mergedFileDestTextBox.Text = "";
            this.mergedFileDestTextBox.Text = mergedFileDest;
        }

        private void browseSourceFileButton_Click(object sender, EventArgs e)
        {
            OpenFileDialog browseSourceFileDialog = new OpenFileDialog();
            browseSourceFileDialog.ShowDialog();
            string sourceFile = browseSourceFileDialog.FileName;
            this.sourceFileTextBox.Text = "";
            this.sourceFileTextBox.Text = sourceFile;
        }

        private void mergeFiles_ControlChanged(object sender, EventArgs e)
        {
            if (checkTextBoxNotEmpty("mergeFilesTab"))
            {
                this.mergeButton.Enabled = true;
            }
            else
            {
                this.mergeButton.Enabled = false;
            }
        }

        private void mergedFilesListBox_DoubleClick(object sender, EventArgs e)
        {
            string filePath = "";
            try
            {
                filePath = mergedFilesListBox.SelectedItem.ToString();
                System.Diagnostics.Process.Start("notepad.exe", filePath);
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error has occurred while trying to open file " + filePath + ": " + ex.ToString());
            }
        }
        #endregion

        #region replaceStrings methods
        private void replaceStringsTextBox_TextChanged(object sender, EventArgs e)
        {
            if (checkTextBoxNotEmpty("replaceStringsTab"))
            {
                this.replaceButton.Enabled = true;
            }
            else
            {
                this.replaceButton.Enabled = false;
            }
        }

        private void replaceButton_Click(object sender, EventArgs e)
        {
            string sourceFile = this.sourceFileTextBox.Text;
            this.replaceStringsResultListBox.Items.Clear();
            string[] newlines;
            ArrayList newlist = new ArrayList();
            if (this.replaceSingleRadioButton.Checked)
            {
                string replaceText = this.replaceTextBox.Text;
                string withText = this.withTextBox.Text;
                try
                {
                    string[] lines = FileHelper.ReadFromFile(sourceFile);
                    newlines = new string[lines.Length];
                    for (int i = 0; i < lines.Length; i++)
                    {
                        if (lines[i].Contains(replaceText))
                        {
                            newlines[i] = lines[i].Replace(replaceText, withText);
                            replaceStringsResultListBox.Items.Add("line " + (i + 1) + " replaced: " + newlines[i]);
                        }
                        else
                        {
                            newlines[i] = lines[i];
                        }
                        newlist.Add(newlines[i]);
                    }
                    FileHelper.WriteToFile(sourceFile, newlist);
                    MessageBox.Show("Number of lines replaced: " + replaceStringsResultListBox.Items.Count);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("An error has occurred while replace text: " + ex.ToString());
                }
            }
            else
            {
                ListBox.ObjectCollection replaceWiths = this.replaceWithListBox.Items;
                string[] replaceArray = new string[replaceWiths.Count];
                string[] withArray = new string[replaceWiths.Count];
                int count = 0;
                foreach (string replaceWith in replaceWiths)
                {
                    replaceArray[count] = replaceWith.Split('~')[0];
                    withArray[count] = replaceWith.Split('~')[1];
                    count++;
                }
                try
                {
                    string[] lines = FileHelper.ReadFromFile(sourceFile);
                    newlines = new string[lines.Length];
                    for (int i = 0; i < lines.Length; i++)
                    {
                        for (int j = 0; j < replaceArray.Length; j++)
                        {
                            if (lines[i].Contains(replaceArray[j]))
                            {
                                newlines[i] = lines[i].Replace(replaceArray[j], withArray[j]);
                                replaceStringsResultListBox.Items.Add("line " + (i + 1) + " replaced: " + newlines[i]);
                                break;
                            }
                            else
                            {
                                newlines[i] = lines[i];
                            }
                        }
                        newlist.Add(newlines[i]);
                    }
                    FileHelper.WriteToFile(sourceFile, newlist);
                    MessageBox.Show("Number of lines replaced: " + replaceStringsResultListBox.Items.Count);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("An error has occurred while replace text: " + ex.ToString());
                }
            }
        }

        private void addReplaceWithButton_Click(object sender, EventArgs e)
        {
            AddReplaceWithForm arwf = new AddReplaceWithForm(this, "", "");
            arwf.Show();
        }

        private void clearReplaceStringsButton_Click(object sender, EventArgs e)
        {
            this.sourceFileTextBox.Text = "";
            this.replaceTextBox.Text = "";
            this.withTextBox.Text = "";
            this.replaceStringsResultListBox.Items.Clear();
            this.replaceWithListBox.Items.Clear();
            this.replaceSingleRadioButton.Checked = false;
            this.replaceManyRadioButton.Checked = false;
        }

        private void replaceWithListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (checkTextBoxNotEmpty("replaceStringsTab"))
            {
                this.replaceButton.Enabled = true;
            }
            else
            {
                this.replaceButton.Enabled = false;
            }
        }

        private void replaceWithListBox_DoubleClick(object sender, EventArgs e)
        {
            string selectedItem = replaceWithListBox.SelectedItem.ToString();
            string[] items = selectedItem.Split('~');
            AddReplaceWithForm arwf = new AddReplaceWithForm(this, items[0], items[1]);
            arwf.Show();
        }

        private void replaceStrings_ControlChanged(object sender, EventArgs e)
        {
            if (checkTextBoxNotEmpty("replaceStringsTab"))
            {
                this.replaceButton.Enabled = true;
            }
            else
            {
                this.replaceButton.Enabled = false;
            }
        }

        private void replaceSingleRadioButton_CheckedChanged(object sender, EventArgs e)
        {
            renderReplaceSingleControls();
        }

        private void renderReplaceSingleControls()
        {
            this.replaceStringsResultListBox.Items.Clear();
            this.replaceStringsTab.Controls.Remove(this.replaceWithLabel);
            this.replaceStringsTab.Controls.Remove(this.replaceWithListBox);
            this.replaceStringsTab.Controls.Remove(this.addReplaceWithButton);
            this.replaceStringsTab.Controls.Add(this.replaceLabel);
            this.replaceStringsTab.Controls.Add(this.replaceTextBox);
            this.replaceStringsTab.Controls.Add(this.withLabel);
            this.replaceStringsTab.Controls.Add(this.withTextBox);
        }

        private void replaceManyRadioButton_CheckedChanged(object sender, EventArgs e)
        {
            renderReplaceManyControls();
        }

        private void renderReplaceManyControls()
        {
            this.replaceStringsResultListBox.Items.Clear();
            this.replaceStringsTab.Controls.Remove(this.replaceLabel);
            this.replaceStringsTab.Controls.Remove(this.replaceTextBox);
            this.replaceStringsTab.Controls.Remove(this.withLabel);
            this.replaceStringsTab.Controls.Remove(this.withTextBox);
            this.replaceStringsTab.Controls.Add(this.replaceWithLabel);
            this.replaceStringsTab.Controls.Add(this.replaceWithListBox);
            this.replaceStringsTab.Controls.Add(this.addReplaceWithButton);
        }
        #endregion

        #region searchContent methods
        private void browseSrcDirButton_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog dia = new FolderBrowserDialog();
            dia.ShowDialog();
            this.srcDirTextBox.Text = "";
            this.srcDirTextBox.Text = dia.SelectedPath;
        }

        private void browseDestFilePathButton_Click(object sender, EventArgs e)
        {
            OpenFileDialog dia = new OpenFileDialog();
            dia.ShowDialog();
            this.destFilePathTextBox.Text = "";
            this.destFilePathTextBox.Text = dia.FileName;
        }

        private void fileTypeDdl_SelectedIndexChanged(object sender, EventArgs e)
        {
            displayGroupBox(this.fileTypeDdl.SelectedItem.ToString());
        }

        private void displayGroupBox(string fileType)
        {
            switch (fileType)
            {
                case ".xml":
                    displayXmlGroupBox();
                    break;
                case ".txt":
                    displayTxtGroupBox();
                    break;
                default:
                    break;
            }
        }

        private void displayXmlGroupBox()
        {
            this.fileTypeGroupBox.Controls.Remove(this.txtContainsTextBox);
            this.fileTypeGroupBox.Controls.Remove(this.txtContainsLabel);
            this.Controls.Remove(this.fileTypeGroupBox);
            this.fileTypeGroupBox.Text = "Filetype : Xml";
            this.fileTypeGroupBox.Controls.Add(this.xmlContainsTextBox);
            this.fileTypeGroupBox.Controls.Add(this.xmlContainsLabel);
            this.fileTypeGroupBox.Controls.Add(this.xmlSearchStrTxtBox);
            this.fileTypeGroupBox.Controls.Add(this.xmlSearchStringsLabel);
            this.fileTypeGroupBox.Controls.Add(this.xmlSearchByTagNameRadioBtn);
            this.fileTypeGroupBox.Controls.Add(this.xmlSearchByIdRadioBtn);
            this.fileTypeGroupBox.Controls.Add(this.xmlSearchByLabel);
            this.searchContentTab.Controls.Add(this.fileTypeGroupBox);
            this.fileTypeGroupBox.ResumeLayout(false);
            this.fileTypeGroupBox.PerformLayout();
            this.ResumeLayout(false);
            this.PerformLayout();
        }

        private void displayTxtGroupBox()
        {
            this.fileTypeGroupBox.Controls.Remove(this.xmlContainsTextBox);
            this.fileTypeGroupBox.Controls.Remove(this.xmlContainsLabel);
            this.fileTypeGroupBox.Controls.Remove(this.xmlSearchStrTxtBox);
            this.fileTypeGroupBox.Controls.Remove(this.xmlSearchStringsLabel);
            this.fileTypeGroupBox.Controls.Remove(this.xmlSearchByTagNameRadioBtn);
            this.fileTypeGroupBox.Controls.Remove(this.xmlSearchByIdRadioBtn);
            this.fileTypeGroupBox.Controls.Remove(this.xmlSearchByLabel);
            this.Controls.Remove(this.fileTypeGroupBox);
            this.fileTypeGroupBox.Text = "Filetype : Txt";
            this.fileTypeGroupBox.Controls.Add(this.txtContainsTextBox);
            this.fileTypeGroupBox.Controls.Add(this.txtContainsLabel);
            this.searchContentTab.Controls.Add(this.fileTypeGroupBox);
            this.fileTypeGroupBox.ResumeLayout(false);
            this.fileTypeGroupBox.PerformLayout();
            this.ResumeLayout(false);
            this.PerformLayout();
        }

        private void searchContentSearchButton_Click(object sender, EventArgs e)
        {
            switch (fileTypeDdl.SelectedItem.ToString())
            {
                case ".xml":
                    displaySearchXmlResult();
                    break;
                case ".txt":
                    displaySearchTxtResult();
                    break;
            }
        }

        private void displaySearchTxtResult()
        {
            try
            {
                string[] results = SearchHelper.ProcessSearchTXTFiles(this.srcDirTextBox.Text, this.txtContainsTextBox.Text.Split(','), this.destFilePathTextBox.Text);
                searchContentResultListBox.Items.Clear();
                foreach (string result in results)
                {
                    if (result != null)
                    {
                        searchContentResultListBox.Items.Add(result.Split('/')[0].Trim() + ".txt found: " + result.Split('/')[1].Trim());
                    }
                    else
                    {
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error has occurred: " + ex.Message);
            }
        }

        private void displaySearchXmlResult()
        {
            string searchBy = this.xmlSearchByTagNameRadioBtn.Checked ? "tagname" : "id";
            try
            {
                string[] results = SearchHelper.ProcessSearchXMLFiles(this.srcDirTextBox.Text, this.xmlContainsTextBox.Text.Split(','), searchBy, this.xmlSearchStrTxtBox.Text.Split(','), this.destFilePathTextBox.Text);
                searchContentResultListBox.Items.Clear();
                foreach (string result in results)
                {
                    if (result != null)
                    {
                        searchContentResultListBox.Items.Add(result.Split('/')[0].Trim() + ".xml found: " + result.Split('/')[1].Trim());
                    }
                    else
                    {
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error has occurred: " + ex.Message);
            }
        }

        private void searchContentResultListBox_DoubleClick(object sender, EventArgs e)
        {
            if (searchContentResultListBox.Items.Count > 0)
            {
                string filepath = "";
                try
                {
                    string item = searchContentResultListBox.SelectedItem.ToString();
                    int length = item.Split(':')[0].Trim().Length;
                    string filename = item.Split(':')[0].Trim().Substring(0, length - 6);
                    filepath = this.srcDirTextBox.Text + "\\" + filename;
                    string ext = filepath.Substring(filepath.Length - 4);
                    switch (ext)
                    {
                        case ".xml":
                            System.Diagnostics.Process.Start("iexplore.exe", filepath);
                            break;
                        case ".txt":
                            int linestrlength = item.Split(':')[1].Trim().Length;
                            string linestr = item.Split(':')[1].Trim().Substring(linestrlength - 4).Trim();
                            int line = Int32.Parse(linestr);
                            //System.Diagnostics.Process.Start("notepad.exe", String.Format("-n{0} {1}", line, filepath));
                            System.Diagnostics.Process.Start("notedpad.exe", filepath);
                            break;
                        default:
                            break;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("An error has occurred while trying to open file " + filepath + ": " + ex.ToString());
                }
            }
        }

        private void clearButton_Click(object sender, EventArgs e)
        {
            this.srcDirTextBox.Text = "";
            this.destFilePathTextBox.Text = "";
            this.xmlContainsTextBox.Text = "separate by \',\'";
            this.xmlSearchByIdRadioBtn.Checked = false;
            this.xmlSearchByTagNameRadioBtn.Checked = false;
            this.xmlSearchStrTxtBox.Text = "separate by \',\'";
            this.txtContainsTextBox.Text = "separate by \',\'";
            this.searchContentResultListBox.Items.Clear();
        }

        private void commonControls_Changed(object sender, EventArgs e)
        {
            if ((checkXmlControlsOkay() || checkTxtControlsOkay()) && checkCommonControlsOkay())
            {
                this.searchContentSearchButton.Enabled = true;
            }
            else
            {
                this.searchContentSearchButton.Enabled = false;
            }
        }

        private void xmlControls_Changed(object sender, EventArgs e)
        {
            if (checkXmlControlsOkay() && checkCommonControlsOkay())
            {
                this.searchContentSearchButton.Enabled = true;
            }
            else
            {
                this.searchContentSearchButton.Enabled = false;
            }
        }

        private void txtControls_Changed(object sender, EventArgs e)
        {
            if (checkTxtControlsOkay() && checkCommonControlsOkay())
            {
                this.searchContentSearchButton.Enabled = true;
            }
            else
            {
                this.searchContentSearchButton.Enabled = false;
            }
        }

        private bool checkCommonControlsOkay()
        {
            bool okay = false;
            okay = !this.srcDirTextBox.Text.Equals("") && !this.destFilePathTextBox.Text.Equals("") && this.fileTypeDdl.SelectedIndex >= 0;
            return okay;
        }

        private bool checkXmlControlsOkay()
        {
            bool okay = false;
            okay = (!this.xmlContainsTextBox.Text.Equals("") || !this.xmlContainsTextBox.Text.Equals("separate by \',\'")) &&
                (this.xmlSearchByIdRadioBtn.Checked || this.xmlSearchByTagNameRadioBtn.Checked) &&
                (!this.xmlSearchStrTxtBox.Text.Equals("") || !this.xmlSearchStrTxtBox.Text.Equals("separate by \',\'"));
            return okay;
        }

        private bool checkTxtControlsOkay()
        {
            bool okay = false;
            okay = !this.txtContainsTextBox.Text.Equals("") || !this.txtContainsTextBox.Text.Equals("separate by \',\'");
            return okay;
        }
        #endregion

        #region common methods
        private bool checkTextBoxNotEmpty(string owner)
        {
            bool result = false;
            if (owner.Equals("searchFilesTab"))
            {
                result = !this.searchResultPathTextBox.Text.Equals("") && !this.searchFilesSourceTextBox.Text.Equals("")
            && !this.searchResultPathTextBox.Text.Equals("") && !this.destinationDirectoryTextBox.Text.Equals("");
            }
            else if (owner.Equals("mergeFilesTab"))
            {
                result = !this.mergedFileDestTextBox.Text.Equals("") && !this.dirToMergeTextBox.Text.Equals("")
                    && (this.emptyLineStyleRadioButton.Checked || this.fileNameStyleRadioButton.Checked)
                    && (this.backupYesRadioButton.Checked || this.backupNoRadioButton.Checked);
            }
            else if (owner.Equals("replaceStringsTab"))
            {
                result = !this.sourceFileTextBox.Text.Equals("") && (this.replaceWithListBox.Items.Count != 0
                    || (!this.replaceTextBox.Text.Equals("") && !this.withTextBox.Text.Equals("")))
                    && (this.replaceSingleRadioButton.Checked || this.replaceManyRadioButton.Checked);
            }
            return result;
        }
        #endregion

        #region helpmenu
        private void howToSearchFilesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            HowToSearchFiles form = new HowToSearchFiles();
            form.ShowDialog();
        }

        private void howToMergeFilesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            HowToMergeFiles form = new HowToMergeFiles();
            form.ShowDialog();
        }

        private void howToReplaceStringsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            HowToReplaceStrings form = new HowToReplaceStrings();
            form.ShowDialog();
        }

        private void howToSearchContentInFilesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            HowToSearchContent form = new HowToSearchContent();
            form.ShowDialog();
        }
        #endregion

        private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FileToolAbout form = new FileToolAbout();
            form.ShowDialog();
        }
    }
}
